package com.bb.blog.code.dubbo;

import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;

import java.io.IOException;
import java.sql.PreparedStatement;

public class DubboClient {
    public static void main(String[] args) throws IOException {

        ApplicationConfig applicationConfig = new ApplicationConfig("yingyong-app");
        RegistryConfig registryConfig = new RegistryConfig("zookeeper://localhost:2181");
        ReferenceConfig referenceConfig = new ReferenceConfig();
        referenceConfig.setRegistry(registryConfig);
        referenceConfig.setInterface(DogService.class);
//        referenceConfig.setUrl("dubbo://localhost:2088/com.bb.blog.code.dubbo.DogService");
        referenceConfig.setApplication(applicationConfig);
        referenceConfig.setLoadbalance("random");

        DogService dogService = (DogService) referenceConfig.get();
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.out.println(dogService.bark());
        System.in.read();
    }
}
